package com.hqbzl.c1.finals;

import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.time.temporal.ValueRange;
import java.util.Date;

import static java.time.temporal.ChronoField.INSTANT_SECONDS;

@Slf4j
public class TestFormat {
    static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static void main(String[] args) {
        final Long aLong = Long.valueOf(1);
        final DateTimeFormatter df = DateTimeFormatter.ofPattern("");
        final TemporalAccessor parse = df.parse("");
//        final ValueRange range = parse.range(INSTANT_SECONDS);
//        System.out.println("range = " + range);
        final ValueRange range1 = parse.range(ChronoField.DAY_OF_WEEK);
        System.out.println("range1 = " + range1);
    }

    public static void main1(String[] args) throws ParseException {
        Date date = DATE_FORMAT.parse("2023-10-31 01:02:03");
        final String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                try {
                    Date date1 = DATE_FORMAT.parse(dateStr);
                    System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date1));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }, "th-" + i).start();
        }
    }
}
